﻿
var checknum = 0;
function matchem(obj) {


    if (obj.checked) {

        if (checknum == 3) {
            obj.checked = false;
            if (g_langID == 2052) {
                alert("最多只能选择三项");

            } else {
                alert("Choose up to three");
            }
            
        }
        else {
            checknum++;
        }
    }
    else {
        checknum--;
    }



}
//2填充投票选项
function fill(keywordArray) {
    var sT = "<li><span  ><input name='keyGp' type='checkbox' onclick='matchem(this)' ";
    var eN = "</span></li>";
    var lastHtml = "";
    var newdata = keywordArray.split('|');
    for (var i = 0; i < newdata.length && i < 11; i++) {


        lastHtml += sT + "value='" + newdata[i] + "'/></span><span style='color:#fff'> " + newdata[i] + eN;


    }


    document.getElementById("keyZone").innerHTML = lastHtml;

}
//1请求已发布的关键字选项
function LoadPost() {
    $.post(
        "/GateService/Vote.aspx?ram=" + new Date().toLocaleString() , { code: g_langID },
         function (data) {


             if (data != "0") {
                 fill(data)

             } else {
                 if (g_langID == 1033) {
                     alert("Net Error");

                 } else {
                     alert("网络连接异常");
                 }
             }


         }
        );





}
//字数检测
function FontSum() {
    alert("helo");
}
//发送调查结果
function sendRes() {

    
    var ches = document.getElementsByName("keyGp");

    var paid = null;


    var chstr = "";
    for (var i = 0; i < ches.length; i++) {


        if (ches[i].checked) {

            chstr += ches[i].value + "|";

        }

    }
   
    if (g_langID == 2052) {
        if ($("#votex").val() == "不超过5个字") {
            $("#votex").val("");




        }
    } else {
        if ($("#votex").val() == "Less than 5 words.") {
            $("#votex").val("");




        }
    }

    if (($("#votex").val() != "" || chstr != "")) {
        
        var ches1 = chstr.split('|');
        if (ches1.length == 2) {
            paid = { "1": ches1[0], code1: g_langID, x: $("#votex").val() };
        }
        if (ches1.length == 3) {
            paid = { "1": ches1[0], "2": ches1[1], code1: g_langID, x: $("#votex").val() };
        }
        if (ches1.length == 4) {
            paid = { "1": ches1[0], "2": ches1[1], "3": ches1[2], code1: g_langID, x: $("#votex").val() };
        }
        $.post(
         "/GateService/Vote.aspx", paid, function (data) {
             if (g_langID == 1033) {
                 $.fn.colorbox({
                     href: "/en/result.html",
                     width: 610,
                     height: 605
                 });
             } else {
                 $.fn.colorbox({
                     href: "/cn/result.html",
                     width: 610,
                     height: 605
                 });
             }



         }
        );

         return true;
    }
     else {
       
         if (g_langID == 1033) {
             alert(" Choose at least one");

         } else {
             alert("至少选择一项");
         }
        return false;
    }

}